//package cetcbigdata.da.personal_service.beijing;
//
//import cn.wanghaomiao.xpath.model.JXDocument;
//import com.alibaba.datax.common.plugin.RecordSender;
//import com.alibaba.fastjson.JSONObject;
//import org.jsoup.nodes.Element;
//import us.codecraft.webmagic.Page;
//import us.codecraft.webmagic.Request;
//import us.codecraft.webmagic.Site;
//import us.codecraft.webmagic.SpiderHB;
//import us.codecraft.webmagic.processor.PageProcessor;
//import us.codecraft.webmagic.utils.HttpConstant;
//
//import java.util.List;
//import java.util.regex.Matcher;
//import java.util.regex.Pattern;
//
///**
// * @author YuanGongPing
// * @version 0.1
// * @description BeijingPersonalCorporateMattersGuide
// * @since 2022/7/21 15:20
// */
//
//
//public class Spidersv0 implements PageProcessor {
//
//    private Site site = Site
//            .me()
//            .setDomain("blog.sina.com.cn")
//            .setSleepTime(3000)
//            .setTimeOut(10000)
//            .setUserAgent(
//                    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31"
//            )
//            .setRetryTimes(2);
//
//
//    public void getData(RecordSender recordSender, List<Object> fieldsList) {
//        PageProcessor pageProcessor = new Spidersv0();
//        SpiderHB spider = SpiderHB.create(pageProcessor);
//        Request request = new Request("http://banshi.beijing.gov.cn/guideservice/pubtask/getTaskList?serverType=1001&locationCode=110000000000&localType=0&businessType=&topicType=&taskName=&deptCode=&taskType=&pageNum=2");
//        request.setMethod(HttpConstant.Method.GET);
//        spider.addRequest(request);
//        spider.addPipeline(new Pipelinesv0(recordSender, fieldsList));
//        spider.thread(3).run();
//    }
//
//
//
//
//    @Override
//    public void process(Page page) {
//        JSONObject res = new JSONObject();
//
//        JXDocument jxDocument = new JXDocument( page.getHtml().toString());
//        List<Object> rs = jxDocument.sel("//*[@id='basic-main']//td[@class='td-name']");
//        for (Object o : rs){
//            String key  = ((Element) o).text();
//            String value = ((Element) o).nextElementSibling().text();
//            res.put(key, value);
//        }
////        page.putField("基本信息",JSONObject.toJSONString(res));
//
//        String regex = "var process = ([\\s\\S]*?);";
//        Pattern pattern = Pattern.compile(regex);
//        Matcher matcher = pattern.matcher(page.getHtml().toString());
//        String data = null;
//        while (matcher.find()) {
//            data = matcher.group();
//            data = data.replace("var process = ", "");
//            data = data.replace(";", "");
//        }
//
//        System.out.println(JSONObject.parseObject(data));
//    }
//
//
//
//    @Override
//    public Site getSite() {
//        return site;
//    }
//
//
//    public static void main(String[] args) {
//        PageProcessor pageProcessor = new Spidersv0();
//        SpiderHB spider = SpiderHB.create(pageProcessor);
//        Request request = new Request("http://banshi.beijing.gov.cn/pubtask/task/1/110000000000/45863962-f03f-4ba8-bbbc-a1b4b66a6e86.html?locationCode=110000000000&serverType=1001#path-main");
//        request.setMethod(HttpConstant.Method.GET);
//        spider.addRequest(request);
//        spider.addPipeline(new Pipelinesv0());
//        spider.thread(3).run();
//    }
//}
